package dao

import (
	"fmt"
	"github.com/jinzhu/gorm"
)

var (
	DB    *gorm.DB
	dbErr error
)

func InitMySql() (err error) {
	dsn := "root:root@tcp(localhost:3306)/todolist?charset=utf8mb4&parseTime=True&loc=Local"
	DB, err = gorm.Open("mysql", dsn)
	if err != nil {
		fmt.Println("连接数据库失败！", dbErr)
		return
	}
	return
}
